package edu.stanford.bmir.protege.web.client.ui.generated;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import com.google.gwt.core.client.GWT;

import edu.stanford.bmir.protege.web.client.metrics.MetricsPortlet;
import edu.stanford.bmir.protege.web.client.project.Project;
import edu.stanford.bmir.protege.web.client.renderer.EntityDescriptionPortlet;
import edu.stanford.bmir.protege.web.client.ui.editor.EditorPortlet;
import edu.stanford.bmir.protege.web.client.ui.frame.OWLEntityDescriptionEditorPortlet;
import edu.stanford.bmir.protege.web.client.ui.notes.DiscussionThreadPortlet;
import edu.stanford.bmir.protege.web.client.ui.obo.OBOTermCrossProductPortlet;
import edu.stanford.bmir.protege.web.client.ui.obo.OBOTermDefinitionPortlet;
import edu.stanford.bmir.protege.web.client.ui.obo.OBOTermIdEditorPortlet;
import edu.stanford.bmir.protege.web.client.ui.obo.OBOTermMetadataPortlet;
import edu.stanford.bmir.protege.web.client.ui.obo.OBOTermRelationshipPortlet;
import edu.stanford.bmir.protege.web.client.ui.obo.OBOTermSynonymsPortlet;
import edu.stanford.bmir.protege.web.client.ui.obo.OBOTermXRefsEditorPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.annotations.OntologyAnnotationsPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.changes.ChangeSummaryPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.changes.ChangesPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.changes.WatchedEntitiesPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.classes.AllPropertiesPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.classes.ClassTreePortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.classes.ClassesTab;
import edu.stanford.bmir.protege.web.client.ui.ontology.classes.PropertiesViewPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.classes.SuperclassesPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.external.STKOSOntologySearch;
import edu.stanford.bmir.protege.web.client.ui.ontology.external.evaluation.STKOSOntologyEvaluation;
import edu.stanford.bmir.protege.web.client.ui.ontology.external.query.STKOSOntologyInference;
import edu.stanford.bmir.protege.web.client.ui.ontology.external.radon.STKOSOntologyDiagnose;
import edu.stanford.bmir.protege.web.client.ui.ontology.hierarchy.ManageHierarchyPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.hierarchy.ManageHierarchyTab;
import edu.stanford.bmir.protege.web.client.ui.ontology.home.OntologiesPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.id.OntologyIdPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.individuals.IndividualsListPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.individuals.IndividualsTab;
import edu.stanford.bmir.protege.web.client.ui.ontology.metadata.AnnotationsPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.metadata.ImportsTreePortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.metadata.MetadataTab;
import edu.stanford.bmir.protege.web.client.ui.ontology.notes.NotesTab;
import edu.stanford.bmir.protege.web.client.ui.ontology.properties.PropertiesTab;
import edu.stanford.bmir.protege.web.client.ui.ontology.properties.PropertiesTreePortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.revisions.RevisionsPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.scene.ScenesMenuPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.scene.ScenesTab;
import edu.stanford.bmir.protege.web.client.ui.ontology.search.BioPortalSearchPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.search.OtherTerminologiesTab;
import edu.stanford.bmir.protege.web.client.ui.ontology.stkos.cutter.StkosCutterTab;
import edu.stanford.bmir.protege.web.client.ui.ontology.stkos.cutter.accordingdesc.StkosCutterAccordingDescriptionPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.stkos.cutter.accordingtree.StkosCutterAccordingTreePortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.stkos.cutter.currentdesc.StkosCutterCurrentDescriptionPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.stkos.cutter.currenttree.StkosCutterCurrentTreePortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.stkos.cutter.option.StkosCutterOptionPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.stkos.cutter.statistical.StkosCutterStatisticalPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.stkos.enricher.StkosEnricherTab;
import edu.stanford.bmir.protege.web.client.ui.ontology.stkos.enricher.currentdesc.StkosEnricherCurrentDescriptionPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.stkos.enricher.currenttree.StkosEnricherCurrentTreePortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.stkos.enricher.option.StkosEnricherOptionPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.stkos.enricher.recommended.StkosEnricherRecommendedPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.stkos.enricher.statistical.StkosEnricherStatisticalPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.stkos.mapper.StkosMapperTab;
import edu.stanford.bmir.protege.web.client.ui.ontology.stkos.mapper.according.StkosMapperAccordingProjectDescriptionPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.stkos.mapper.according.StkosMapperAccordingProjectTreePortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.stkos.mapper.current.StkosMapperCurrentProjectDescriptionPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.stkos.mapper.current.StkosMapperCurrentProjectTreePortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.stkos.mapper.option.StkosMapperOptionPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.stkos.mapper.statistical.StkosMapperStatisticalPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.stkos.merger.StkosMergerTab;
import edu.stanford.bmir.protege.web.client.ui.ontology.stkos.merger.accordingdesc.StkosMergerAccordingDescriptionPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.stkos.merger.accordingtree.StkosMergerAccordingTreePortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.stkos.merger.currentdesc.StkosMergerCurrentDescriptionPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.stkos.merger.currenttree.StkosMergerCurrentTreePortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.stkos.merger.option.StkosMergerOptionPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.stkos.merger.statistical.StkosMergerStatisticalPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.stkos.test.TestPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.stkos.test.TestTab;
import edu.stanford.bmir.protege.web.client.ui.ontology.stkos.visualizer.StkosVisualizerTab;
import edu.stanford.bmir.protege.web.client.ui.ontology.stkos.visualizer.ui.StkosVisualizerPortlet;
import edu.stanford.bmir.protege.web.client.ui.ontology.transform.TransformProtlet;
import edu.stanford.bmir.protege.web.client.ui.portlet.EntityPortlet;
import edu.stanford.bmir.protege.web.client.ui.portlet.bioportal.BioPortalProposalsPortlet;
import edu.stanford.bmir.protege.web.client.ui.portlet.html.HtmlMessagePortlet;
import edu.stanford.bmir.protege.web.client.ui.portlet.propertyForm.PropertyFieldPortlet;
import edu.stanford.bmir.protege.web.client.ui.projectfeed.ProjectFeedPortlet;
import edu.stanford.bmir.protege.web.client.ui.tab.AbstractTab;
import edu.stanford.bmir.protege.web.client.ui.tab.UserDefinedTab;
import edu.stanford.bmir.protege.web.client.usage.UsagePortlet;

/**
 * This class is supposed to be automatically generated by the GWT generator at
 * compile time. In the current version it is not.
 * <p/>
 * This is a factory class that will provide create methods for all tabs and
 * portlets. The UI configurator will use this class to layout the UI for a
 * particular project and user.
 * <p/>
 * This factory tries to compensate for the lack of reflection support in GWT
 * and JS.
 * 
 * @author Tania Tudorache <tudorache@stanford.edu>
 */
public class UIFactory {

	public static final String PORTLET_SUFFIX = "Portlet";
	
	 public static final Map<String,AbstractTab> maps = new HashMap<String,AbstractTab>();

	/*
	 * Tab factory
	 */

	public static AbstractTab createTab(Project project, String tabJavaClassName) {
		if (tabJavaClassName.equals(ClassesTab.class.getName())) {
			return new ClassesTab(project);
		} else if (tabJavaClassName.equals(PropertiesTab.class.getName())) {
			return new PropertiesTab(project);
		} else if (tabJavaClassName.equals(IndividualsTab.class.getName())) {
			return new IndividualsTab(project);
		} else if (tabJavaClassName.equals(NotesTab.class.getName())) {
			return new NotesTab(project);
		} else if (tabJavaClassName.equals(OtherTerminologiesTab.class
				.getName())) {
			return new OtherTerminologiesTab(project);
		} else if (tabJavaClassName.equals(UserDefinedTab.class.getName())) {
			return new UserDefinedTab(project);
		} else if (tabJavaClassName.equals(ManageHierarchyTab.class.getName())) {
			return new ManageHierarchyTab(project);
		} 
		//医科工具
		 else if (tabJavaClassName.equals(StkosMapperTab.class.getName())) {
				return new StkosMapperTab(project);
		 } 
		 else if (tabJavaClassName.equals(StkosVisualizerTab.class.getName())) {
				return new StkosVisualizerTab(project);
		 } 
		 else if (tabJavaClassName.equals(StkosCutterTab.class.getName())) {
				return new StkosCutterTab(project);
		 } 
		 else if (tabJavaClassName.equals(StkosEnricherTab.class.getName())) {
				return new StkosEnricherTab(project);
		 } 
		 else if (tabJavaClassName.equals(StkosMergerTab.class.getName())) {
				return new StkosMergerTab(project);
		 } 
		 else if (tabJavaClassName.equals(TestTab.class.getName())) {
				return new TestTab(project);
		 } 
		 else if ( tabJavaClassName.equals( ScenesTab.class.getName() ) ) {
	        	ScenesTab scenesTab =new ScenesTab(project);
	        	maps.put( "key" , scenesTab);
	        	return scenesTab;
	      }
		//醫科工具
		
		return null;
	}

	/*
	 * Portlet factory
	 */

	public static EntityPortlet createPortlet(Project project,
			String portletJavaClassName) {
		try {
			if (portletJavaClassName.equals(AllPropertiesPortlet.class
					.getName())) {
				return new AllPropertiesPortlet(project);
			} else if (portletJavaClassName.equals(AnnotationsPortlet.class
					.getName())) {
				return new AnnotationsPortlet(project);
			} else if (portletJavaClassName.equals(ClassTreePortlet.class
					.getName())) {
				return new ClassTreePortlet(project);
			} else if (portletJavaClassName.equals(ImportsTreePortlet.class
					.getName())) {
				return new ImportsTreePortlet(project);
			} else if (portletJavaClassName.equals(IndividualsListPortlet.class
					.getName())) {
				return new IndividualsListPortlet(project);
			} else if (portletJavaClassName.equals(MetricsPortlet.class
					.getName())) {
				return new MetricsPortlet(project);
			} else if (portletJavaClassName.equals(PropertiesTreePortlet.class
					.getName())) {
				return new PropertiesTreePortlet(project);
			} else if (portletJavaClassName.equals(PropertyFieldPortlet.class
					.getName())) {
				return new PropertyFieldPortlet(project);
			} else if (portletJavaClassName.equals(BioPortalSearchPortlet.class
					.getName())) {
				return new BioPortalSearchPortlet(project);
			} else if (portletJavaClassName.equals(ChangeSummaryPortlet.class
					.getName())) {
				return new ChangeSummaryPortlet(project);
			} else if (portletJavaClassName.equals(WatchedEntitiesPortlet.class
					.getName())) {
				return new WatchedEntitiesPortlet(project);
			} else if (portletJavaClassName.equals(ManageHierarchyPortlet.class
					.getName())) {
				return new ManageHierarchyPortlet(project);
			} else if (portletJavaClassName.equals(HtmlMessagePortlet.class
					.getName())) {
				return new HtmlMessagePortlet(project);
			} else if (portletJavaClassName.equals(SuperclassesPortlet.class
					.getName())) {
				return new SuperclassesPortlet(project);
			} else if (portletJavaClassName.equals(ChangesPortlet.class
					.getName())) {
				return new ChangesPortlet(project);
			} else if (portletJavaClassName.equals(WatchedEntitiesPortlet.class
					.getName())) {
				return new WatchedEntitiesPortlet(project);
			} else if (portletJavaClassName.equals(PropertiesViewPortlet.class
					.getName())) {
				return new PropertiesViewPortlet(project);
			} else if (portletJavaClassName
					.equals(BioPortalProposalsPortlet.class.getName())) {
				return new BioPortalProposalsPortlet(project);
			} else if (portletJavaClassName
					.equals(OBOTermRelationshipPortlet.class.getName())) {
				return new OBOTermRelationshipPortlet(project);
			} else if (portletJavaClassName
					.equals(OBOTermDefinitionPortlet.class.getName())) {
				return new OBOTermDefinitionPortlet(project);
			} else if (portletJavaClassName.equals(OBOTermIdEditorPortlet.class
					.getName())) {
				return new OBOTermIdEditorPortlet(project);
			} else if (portletJavaClassName.equals(OBOTermMetadataPortlet.class
					.getName())) {
				return new OBOTermMetadataPortlet(project);
			} else if (portletJavaClassName.equals(OBOTermSynonymsPortlet.class
					.getName())) {
				return new OBOTermSynonymsPortlet(project);
			} else if (portletJavaClassName
					.equals(OBOTermCrossProductPortlet.class.getName())) {
				return new OBOTermCrossProductPortlet(project);
			} else if (portletJavaClassName
					.equals(OBOTermXRefsEditorPortlet.class.getName())) {
				return new OBOTermXRefsEditorPortlet(project);
			} else if (portletJavaClassName.equals(RevisionsPortlet.class
					.getName())) {
				return new RevisionsPortlet(project);
			} else if (portletJavaClassName.equals(OntologyIdPortlet.class
					.getName())) {
				return new OntologyIdPortlet(project);
			} else if (portletJavaClassName
					.equals(OntologyAnnotationsPortlet.class.getName())) {
				return new OntologyAnnotationsPortlet(project);
			} else if (portletJavaClassName.equals(ProjectFeedPortlet.class
					.getName())) {
				return new ProjectFeedPortlet(project);
			} else if (portletJavaClassName
					.equals(DiscussionThreadPortlet.class.getName())) {
				return new DiscussionThreadPortlet(project);
			} else if (portletJavaClassName.equals(EditorPortlet.class
					.getName())) {
				return new EditorPortlet(project);
			} else if (portletJavaClassName
					.equals(UsagePortlet.class.getName())) {
				return new UsagePortlet(project);
			} else if (portletJavaClassName
					.equals(EntityDescriptionPortlet.class.getName())) {
				return new EntityDescriptionPortlet(project);
			} else if (portletJavaClassName
					.endsWith(OWLEntityDescriptionEditorPortlet.class.getName())) {
				return new OWLEntityDescriptionEditorPortlet(project);
			} else if (portletJavaClassName
					.endsWith(STKOSOntologySearch.class.getName())) {
				return new STKOSOntologySearch(project);
			} else if (portletJavaClassName
					.endsWith(STKOSOntologyInference.class.getName())) {
				return new STKOSOntologyInference(project);
			} else if (portletJavaClassName.endsWith(STKOSOntologyDiagnose.class
					.getName())) {
				return new STKOSOntologyDiagnose(project);
			} else if (portletJavaClassName
					.endsWith(STKOSOntologyEvaluation.class.getName())) {
				return new STKOSOntologyEvaluation(project, true);
			}
			//一顆工具
			//mapper portlets
            else if(portletJavaClassName.endsWith(StkosMapperOptionPortlet.class.getName())) {
            	return new StkosMapperOptionPortlet(project);
            }
            else if(portletJavaClassName.endsWith(StkosMapperStatisticalPortlet.class.getName())) {
            	return new StkosMapperStatisticalPortlet(project);
            }
            else if(portletJavaClassName.endsWith(StkosMapperAccordingProjectDescriptionPortlet.class.getName())) {
            	return new StkosMapperAccordingProjectDescriptionPortlet(project);
            }
            else if(portletJavaClassName.endsWith(StkosMapperAccordingProjectTreePortlet.class.getName())) {
            	return new StkosMapperAccordingProjectTreePortlet(project);
            }
            else if(portletJavaClassName.endsWith(StkosMapperCurrentProjectDescriptionPortlet.class.getName())) {
            	return new StkosMapperCurrentProjectDescriptionPortlet(project);
            }
            else if(portletJavaClassName.endsWith(StkosMapperCurrentProjectTreePortlet.class.getName())) {
            	return new StkosMapperCurrentProjectTreePortlet(project);
            }
            //visualizer portlets
            else if(portletJavaClassName.endsWith(StkosVisualizerPortlet.class.getName())) {
            	return new StkosVisualizerPortlet(project);
            }
            //cutter portlets
            else if(portletJavaClassName.endsWith(StkosCutterOptionPortlet.class.getName())) {
            	return new StkosCutterOptionPortlet(project);
            }
            else if(portletJavaClassName.endsWith(StkosCutterStatisticalPortlet.class.getName())) {
            	return new StkosCutterStatisticalPortlet(project);
            }
            else if(portletJavaClassName.endsWith(StkosCutterCurrentTreePortlet.class.getName())) {
            	return new StkosCutterCurrentTreePortlet(project);
            }
            else if(portletJavaClassName.endsWith(StkosCutterAccordingTreePortlet.class.getName())) {
            	return new StkosCutterAccordingTreePortlet(project);
            }
            else if(portletJavaClassName.endsWith(StkosCutterCurrentDescriptionPortlet.class.getName())) {
            	return new StkosCutterCurrentDescriptionPortlet(project);
            }
            else if(portletJavaClassName.endsWith(StkosCutterAccordingDescriptionPortlet.class.getName())) {
            	return new StkosCutterAccordingDescriptionPortlet(project);
            }
            //enricher portlets
            else if(portletJavaClassName.endsWith(StkosEnricherOptionPortlet.class.getName())) {
            	return new StkosEnricherOptionPortlet(project);
            }
            else if(portletJavaClassName.endsWith(StkosEnricherStatisticalPortlet.class.getName())) {
            	return new StkosEnricherStatisticalPortlet(project);
            }
            else if(portletJavaClassName.endsWith(StkosEnricherRecommendedPortlet.class.getName())) {
            	return new StkosEnricherRecommendedPortlet(project);
            }
            else if(portletJavaClassName.endsWith(StkosEnricherCurrentTreePortlet.class.getName())) {
            	return new StkosEnricherCurrentTreePortlet(project);
            }
            else if(portletJavaClassName.endsWith(StkosEnricherCurrentDescriptionPortlet.class.getName())) {
            	return new StkosEnricherCurrentDescriptionPortlet(project);
            }
            //merger portlets
            else if(portletJavaClassName.endsWith(StkosMergerOptionPortlet.class.getName())) {
            	return new StkosMergerOptionPortlet(project);
            }
            else if(portletJavaClassName.endsWith(StkosMergerStatisticalPortlet.class.getName())) {
            	return new StkosMergerStatisticalPortlet(project);
            }
            else if(portletJavaClassName.endsWith(StkosMergerCurrentTreePortlet.class.getName())) {
            	return new StkosMergerCurrentTreePortlet(project);
            }
            else if(portletJavaClassName.endsWith(StkosMergerAccordingTreePortlet.class.getName())) {
            	return new StkosMergerAccordingTreePortlet(project);
            }
            else if(portletJavaClassName.endsWith(StkosMergerCurrentDescriptionPortlet.class.getName())) {
            	return new StkosMergerCurrentDescriptionPortlet(project);
            }
            else if(portletJavaClassName.endsWith(StkosMergerAccordingDescriptionPortlet.class.getName())) {
            	return new StkosMergerAccordingDescriptionPortlet(project);
            }
            // test portlet
            else if(portletJavaClassName.endsWith(TestPortlet.class.getName())) {
            	return new TestPortlet(project);
            }
			//九瑞工具
            else if(portletJavaClassName.endsWith(TransformProtlet.class.getName())) {
            	return new TransformProtlet(project);
            }
            else if(portletJavaClassName.endsWith(ScenesMenuPortlet.class.getName())) {
            	return new ScenesMenuPortlet(project);
            }
		} catch (Exception e) {
			GWT.log("Error when creating portlet", e);
		}
		return null;
	}

	// TODO: taking out ManageHierarchyTab.class.getName() - must be de-icd-ezed
	public static List<String> getAvailableTabNames() {
		/*
		 * Removed tabs: OtherTerminologiesTab.class.getName(),
		 */
		String[] tabs = { ClassesTab.class.getName(),
				PropertiesTab.class.getName(), IndividualsTab.class.getName(),
				MetadataTab.class.getName(), NotesTab.class.getName()
				// stkosutil portlets BEGIN
        		,StkosMapperTab.class.getName()
        		,StkosVisualizerTab.class.getName()
        		,StkosCutterTab.class.getName()
        		,StkosEnricherTab.class.getName()
        		,StkosMergerTab.class.getName()
        		,TestTab.class.getName()
        		// stkosutil portlets END
        		};
		return Arrays.asList(tabs);
	}

	public static List<String> getAvailablePortletNames() {
		/*
		 * Removed portlets: PropertyFieldPortlet.class.getName()
		 * ChangeTreePortlet.class.getName(),
		 * ChangeSummaryPortlet.class.getName(),
		 * ChangeTablePortlet.class.getName(), NotesPortlet.class.getName(),
		 */
		 String[] portlets =
		 {OWLEntityDescriptionEditorPortlet.class.getName(),   EntityDescriptionPortlet.class.getName(),   UsagePortlet.class.getName(), OntologyIdPortlet.class.getName(),   OntologyAnnotationsPortlet.class.getName(),   EditorPortlet.class.getName(),   DiscussionThreadPortlet.class.getName(),   ChangeSummaryPortlet.class.getName(),   ProjectFeedPortlet.class.getName(),   AnnotationsPortlet.class.getName(),   AllPropertiesPortlet.class.getName(),   PropertiesViewPortlet.class.getName(),   ClassTreePortlet.class.getName(), ImportsTreePortlet.class.getName(),   IndividualsListPortlet.class.getName(),   MetricsPortlet.class.getName(), OntologiesPortlet.class.getName(),   PropertiesTreePortlet.class.getName(),   BioPortalSearchPortlet.class.getName(),   SuperclassesPortlet.class.getName(), ChangesPortlet.class.getName(),   WatchedEntitiesPortlet.class.getName(),   BioPortalProposalsPortlet.class.getName(),   OBOTermCrossProductPortlet.class.getName(),   OBOTermRelationshipPortlet.class.getName(),   OBOTermSynonymsPortlet.class.getName(),   OBOTermMetadataPortlet.class.getName(),   OBOTermIdEditorPortlet.class.getName(),   OBOTermDefinitionPortlet.class.getName(),   OBOTermXRefsEditorPortlet.class.getName(),   RevisionsPortlet.class.getName(),STKOSOntologySearch.class.getName(),STKOSOntologyInference.class.getName(),STKOSOntologyDiagnose.class.getName(),STKOSOntologyEvaluation.class.getName()
				// stkosutil portlets BEGIN
	        		,StkosMapperOptionPortlet.class.getName(),StkosMapperStatisticalPortlet.class.getName(),StkosMapperAccordingProjectDescriptionPortlet.class.getName(),StkosMapperAccordingProjectTreePortlet.class.getName(),StkosMapperCurrentProjectDescriptionPortlet.class.getName(),StkosMapperCurrentProjectTreePortlet.class.getName()
	        		,StkosVisualizerPortlet.class.getName()
	        		,StkosCutterOptionPortlet.class.getName(),StkosCutterStatisticalPortlet.class.getName(),StkosCutterCurrentTreePortlet.class.getName(),StkosCutterCurrentDescriptionPortlet.class.getName(),StkosCutterAccordingTreePortlet.class.getName(),StkosCutterAccordingDescriptionPortlet.class.getName()
	        		,StkosEnricherOptionPortlet.class.getName(),StkosEnricherStatisticalPortlet.class.getName(),StkosEnricherCurrentTreePortlet.class.getName(),StkosEnricherCurrentDescriptionPortlet.class.getName(),StkosEnricherRecommendedPortlet.class.getName()
	        		,StkosMergerOptionPortlet.class.getName(),StkosMergerStatisticalPortlet.class.getName(),StkosMergerCurrentTreePortlet.class.getName(),StkosMergerCurrentDescriptionPortlet.class.getName(),StkosMergerAccordingTreePortlet.class.getName(),StkosMergerAccordingDescriptionPortlet.class.getName()
	        		,TestPortlet.class.getName(),TransformProtlet.class.getName()
		 };

		List<String> portletsList = Arrays.asList(portlets);
		Collections.sort(portletsList, new Comparator<String>() {
			public int compare(String p1, String p2) {
				String n1 = p1.substring(p1.lastIndexOf(".") + 1);
				String n2 = p2.substring(p2.lastIndexOf(".") + 1);
				return n1.compareTo(n2);
			}
		});
		return portletsList;
	}

	/*
	 * Generic utils
	 */

	public static List<String> getAvailableTabShortNames() {
		List<String> tabs = getAvailableTabNames();
		List<String> shortNames = new ArrayList<String>();
		for (String tab : tabs) {
			shortNames.add(tab.substring(tab.lastIndexOf(".") + 1));
		}
		return shortNames;
	}

	/**
	 * @return A map from the short names of the portlets to the full java class
	 *         name of the portlets.
	 */
	public static Map<String, String> getAvailablePortletNameMap() {
		List<String> portlets = getAvailablePortletNames();
		Map<String, String> map = new LinkedHashMap<String, String>();
		for (String portlet : portlets) {
			map.put(getPortletShortName(portlet), portlet);
		}
		return map;
	}

	/**
	 * Extracts a short human readable name from a portlet java class name.
	 * 
	 * @param portletClassName
	 *            The fully qualified class name for the portlet
	 * @return The short name for the portlet (not null).
	 */
	private static String getPortletShortName(String portletClassName) {
		int simpleNameSeparator = portletClassName.lastIndexOf(".");
		if (simpleNameSeparator == -1) {
			return portletClassName;
		}
		String simpleName = portletClassName.substring(simpleNameSeparator + 1);
		String strippedName;
		if (simpleName.endsWith(PORTLET_SUFFIX)) {
			strippedName = simpleName.substring(0, simpleName.length()
					- PORTLET_SUFFIX.length());
		} else {
			strippedName = simpleName;
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < strippedName.length(); i++) {
			char ch = strippedName.charAt(i);
			boolean upperCase = Character.isUpperCase(ch);
			if (upperCase) {
				if (isNextCharacterLowerCase(strippedName, i)
						|| isPreviousCharacterLowerCase(strippedName, i)) {
					sb.append(" ");
				}
			}
			sb.append(ch);
		}
		return sb.toString().trim();
	}

	private static boolean isPreviousCharacterLowerCase(String strippedName,
			int i) {
		return i > 0 && Character.isLowerCase(strippedName.charAt(i - 1));
	}

	private static boolean isNextCharacterLowerCase(String s, int currentIndex) {
		return currentIndex < s.length() - 1
				&& Character.isLowerCase(s.charAt(currentIndex + 1));
	}

	/**
	 * @return A map from the short names of tabs (label) to the full java class
	 *         name of the tabs.
	 */
	public static Map<String, String> getAvailableTabNameMap() {
		List<String> tabs = getAvailableTabNames();
		Collections.sort(tabs);
		Map<String, String> map = new LinkedHashMap<String, String>();
		for (String tab : tabs) {
			map.put(tab.substring(tab.lastIndexOf(".") + 1), tab);
		}
		return map;
	}

}
